#include <QPainter>
#include "JZImageGraphic.h"

JZGraphic::JZGraphic()
{
    type = None;
}

void JZGraphic::draw(QPainter *painter)
{       
    painter->setPen(QPen(color, 4));

    switch (type)
    {
    case JZGraphic::Point:
        painter->drawPoint(points[0]);
        break;
    case JZGraphic::Line:
        painter->drawLine(points[0], points[1]);
        break;
    case JZGraphic::Text:
        painter->drawText(points[0], text);
        break;
    case JZGraphic::TextBox:
        painter->drawText(QRect(points[0], points[1]), text, QTextOption(textAlign));
        break;
    case JZGraphic::Circle:
    {
        painter->drawEllipse(QRect(points[0], points[1]));
        break;
    }
    case JZGraphic::Rect:
        painter->drawRect(QRect(points[0], points[1]));
        break;
    case JZGraphic::Polygon:
    {
        painter->drawPolygon(QPolygon(points));
        break;
    }
    case JZGraphic::Ellipse:
        painter->drawEllipse(QRect(points[0], points[1]));
        break;
    default:
        break;
    }    
}